//
//  LYHallViewController.m
//  lottery
//
//  Created by 赵国腾 on 16/6/10.
//  Copyright © 2016年 赵国腾. All rights reserved.
//

#import "LYHallViewController.h"
#import "LYCover.h"
#import "LYActiveMenu.h"
#import "LYDownMenu.h"
#import "LYMenuItem.h"

@interface LYHallViewController ()<LYActiveMenuDelegate>

@property (nonatomic, weak) LYDownMenu *downMenu;
@property (nonatomic, assign) BOOL isPopMenu;

@end

@implementation LYHallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    NSLog(@"%@", NSHomeDirectory());
    
    // 导航条设置
    [self setupNavi];
}

- (void)setupNavi {
    
    // 左边按钮
    UIImage *leftImage = [UIImage imageWithOriRenderingImage:@"CS50_activity_image"];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:leftImage style:UIBarButtonItemStylePlain target:self action:@selector(leftItemClick)];
    
//    右边按钮
    UIImage *rightImage = [UIImage imageWithOriRenderingImage:@"Development"];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:rightImage style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick)];

}

- (void)leftItemClick {
    
    [LYCover show];
    
    LYActiveMenu *activeMenu = [LYActiveMenu showInPoint:self.view.center];
    
    activeMenu.delegate = self;
    
    NSLog(@"%s", __func__);
}

#pragma mark - <LYActiveMenuDelegate>

- (void)activeMenuDidClickCloseBtn:(LYActiveMenu *)activeMenu {
    
    [LYActiveMenu hideInPoint:CGPointMake(44, 44) completion:^{
        
        [LYCover hide];
    }];
}


#pragma mark -  点击菜单按钮调用

- (LYDownMenu *)downMenu {
    
    if (_downMenu == nil) {
        _downMenu = [LYDownMenu showInView:self.view items:[LYMenuItem menuItems] oriY:0];
    }
    
    return _downMenu;
}

- (void)rightItemClick {
    
    if (_isPopMenu == NO) {
        
        [self downMenu];
    }else {
        
//        [LYDownMenu hide];
        [self.downMenu hide];
    }
    
    self.isPopMenu = !_isPopMenu;
    
    NSLog(@"%s", __func__);
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
